import tkinter as tk
from tkinter import simpledialog, messagebox

students = {}

def add_student():
    id = simpledialog.askstring("添加学员", "请输入学员ID：")
    name = simpledialog.askstring("添加学员", "请输入学员姓名：")
    age = simpledialog.askstring("添加学员", "请输入学员年龄：")
    phone = simpledialog.askstring("添加学员", "请输入学员电话：")
    students[id] = {'name': name, 'age': age, 'phone': phone}

def delete_student():
    id = simpledialog.askstring("删除学员", "请输入要删除的学员ID：")
    if id in students:
        del students[id]
    else:
        messagebox.showinfo("错误", "学员不存在")

def modify_student():
    id = simpledialog.askstring("修改学员信息", "请输入要修改的学员ID：")
    if id in students:
        name = simpledialog.askstring("修改学员信息", "请输入新的学员姓名：")
        age = simpledialog.askstring("修改学员信息", "请输入新的学员年龄：")
        phone = simpledialog.askstring("修改学员信息", "请输入新的学员电话：")
        students[id] = {'name': name, 'age': age, 'phone': phone}
    else:
        messagebox.showinfo("错误", "学员不存在")

def query_student():
    id = simpledialog.askstring("查询学员信息", "请输入要查询的学员ID：")
    if id in students:
        messagebox.showinfo("学员信息", str(students[id]))
    else:
        messagebox.showinfo("错误", "学员不存在")

def display_all_students():
    info = ""
    for id, student in students.items():
        info += f"ID: {id}, 姓名: {student['name']}, 年龄: {student['age']}, 电话: {student['phone']}\n"
    messagebox.showinfo("所有学员信息", info)

root = tk.Tk()
root.geometry("600x400")

add_button = tk.Button(root, text="添加学员", command=add_student, font=('Arial', 14), width=20, height=2)
add_button.pack()

delete_button = tk.Button(root, text="删除学员", command=delete_student, font=('Arial', 14), width=20, height=2)
delete_button.pack()

modify_button = tk.Button(root, text="修改学员信息", command=modify_student, font=('Arial', 14), width=20, height=2)
modify_button.pack()

query_button = tk.Button(root, text="查询学员信息", command=query_student, font=('Arial', 14), width=20, height=2)
query_button.pack()

display_button = tk.Button(root, text="显示所有学员信息", command=display_all_students, font=('Arial', 14), width=20, height=2)
display_button.pack()

root.mainloop()